package com.example.demoxstanggiam;

import java.util.ArrayList;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class myAdapter extends ArrayAdapter<Object> {
	private MainActivity activity ;
	private ImageView imageView ;
	int customlayout;
	ArrayList<Object> listds ;

	public myAdapter(MainActivity activity, int customlayout,ArrayList<Object> listds) {
		super(activity, customlayout,listds);
		this.activity = activity ;
		this.customlayout = customlayout ;
		this.listds = listds ;
		
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View v = convertView;
		if (v == null) {
			v = new CustomListViewActivity(activity);
		}
		Object e = listds.get(position);
		if (e != null) {
			ImageView image = ((CustomListViewActivity) v).image;
			TextView tentruyen = ((CustomListViewActivity) v).tentruyen;
			TextView tacgia = ((CustomListViewActivity) v).tacgia;
			TextView gia = ((CustomListViewActivity) v).gia;
			
			image.setBackgroundResource(listds.get(position).getImageanh());
			tentruyen.setText(listds.get(position).getTentruyen());
			tacgia.setText(listds.get(position).getTacgia());
			gia.setText(listds.get(position).getGia()+"");
		}
		return v;
	}
}
